using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace ConsoleApplication_01
{
    [CLSCompliant(true)]
    public enum RuleTypes
    {
        Numerical,
        Text,
        None
    }
    
    [CLSCompliant(true)]
    public delegate bool RuleDelegate(object target);
    
    [CLSCompliant(true)]
    public class Rule
    {
        private readonly RuleDelegate _ruleDelegate;

        public RuleTypes RuleType { get; private set; }
        public string Description { get; private set; }

        public Rule(RuleDelegate ruleDelegate, RuleTypes ruleType, string description)
        {
            _ruleDelegate = ruleDelegate;
            RuleType = ruleType;
            Description = description;
        }

        public bool Check(object target)
        {
            try
            {
                return _ruleDelegate(target);
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                throw;
            }
        }
    }

    [CLSCompliant(true)]
    public static class RulesChecker
    {
        public static bool Check(object target, IList<Rule> rules)
        {
            foreach (Rule rule in rules)
                if (rule.Check(target)) continue;
                else return false;
            return true;
        }
    }
}